
import java.util.*;
public class Main
{
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        char[] s = in.next().toCharArray();
        int[] sum = new int[2]; // 统计字符串中所有 0 和 1 的个数
        for(int i = 0; i < n; i++) {
            sum[s[i] - '0']++;
        }
        int left = 0, right = 0, ret = 0, half = n / 2;
        int[] count = new int[2]; // 统计窗⼝内 0 和 1 的个数
        while(right < n - 1)  {// 细节问题
            count[s[right] - '0']++;
            while(right - left + 1 > half) {
                count[s[left++] - '0']--;
            } if(right - left + 1 == half) {
                if(count[0] * 2 == sum[0] && count[1] * 2 == sum[1]) {
                    ret += 2;
                }
            }
            right++;
        }
        System.out.println(ret);
    }
}
